//
//  RDeliveryJsonModelMediator.h
//  RDelivery
//
//  Created by selmerzhang on 2022/7/18.
//  Copyright © 2022 Tencent. All rights reserved.
//

#ifndef RDeliveryJsonModelMediator_h
#define RDeliveryJsonModelMediator_h

#import "RDeliveryYYModelProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface RDeliveryJsonModelMediator : NSObject

/// 根据注入初始化中间层
/// @param jsonModelImpl 实现了RDeliveryYYModelProtocol协议的实例，默认是YYModel
- (instancetype)initWithImpl:(id<RDeliveryYYModelProtocol>)jsonModelImpl;

/**
 通过json创建model实例对象
 
 @param json  A json object in `NSDictionary`, `NSString` or `NSData`.
 @param cls the class of the object
 
 @return A new instance created from the json, or nil if an error occurs.
 */
- (id)modelWithJSON:(id)json classType:(Class)cls;

/**
 通过model对象生成json数据
 
 @param object  要生成json数据的对象
 
 @return A json string's data, or nil if an error occurs.
 
 @discussion Any of the invalid property is ignored.
 If the reciver is `NSArray`, `NSDictionary` or `NSSet`, it will also convert the
 inner object to json string.
 */
- (nullable NSData *)modelToJSONData:(id)object;

@end

NS_ASSUME_NONNULL_END


#endif /* RDeliveryYYModelMediator_h */
